<template>
  <TXMap
        :latitude="latitude"
        :longitude="longitude"
        @addressInfo ="addressInfo"
        />
</template>

<script>
import TXMap from "@/components/TXMap";
export default {
    name: 'MyLocation',
    data() {
        return {
            latitude:'',
            longitude:'',
            value:''
        }
    }, 
    components: {
        TXMap
    },
    created() {
            var map=new Map();
            var data = {
                key: "4WPBZ-K2XW4-VZRU3-XKQAA-2IHAJ-H5BJ2"  //这个key就是你申请的密钥
            }; 
            var url = "https://apis.map.qq.com/ws/location/v1/ip"; //这个就是地理位置信息的接口
            data.output = "jsonp";
            this.$jsonp(url, data)
                .then(res => {
                    this.latitude = res.result.location.lat;
                    this.longitude = res.result.location.lng;
                    this.value = res.result.ad_info.city;
                    console.log(res);
                //   console.log(this.latitude); 
                })
                .catch(error => {
                    console.log(error);
                });
        },
    methods: {
        addressInfo(title) {
            this.value = title;
            console.log("this is mylocation"+title);
            // this.$emit('onEmitTitle',title);//传地址回index
        }
    }
}
</script>

<style>

</style>